热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

为什么
是flex容器?-Whycan't
beflexcontainers?

Itriedtostyleafieldsetelementwithdisplay:flexanddisplay:inline-flex.我尝试用display:flex和d

I tried to style a fieldset element with display: flex and display: inline-flex.

我尝试用display: flex和display: inline-flex设计一个fieldset元素。

However, it didn't work: flex behaved like block, and inline-flex behaved like inline-block.

但是,它不起作用:flex表现得像块,而inline-flex表现得像块。

This happens both on Firefox and Chrome, but strangely it works on IE.

这在Firefox和Chrome上都有发生,但奇怪的是它在IE上也能起作用。

Is it a bug? I couldn't find that fieldset should have any special behavior, neither in HTML5 nor in CSS Flexible Box Layout specs.

这是一个错误吗?我发现fieldset不应该有任何特殊的行为,无论是在HTML5还是在CSS的灵活框布局规范中。

fieldset, div {
    display: flex;
    border: 1px solid;
}

foo

bar

foo

bar

5 个解决方案

#1


84  

According to Bug 984869 - display: flex doesn't work for button elements,

根据Bug 984869 - display: flex不适用于按钮元素,

This isn't specific to flexbox -- e.g. we don't render scrollbars if you put overflow:scroll on a button, and we don't render it as a table if you put display:table on it.

这并不是flexbox特有的——例如,如果你添加了overflow,我们就不会渲染滚动条:在一个按钮上滚动,如果你添加display:table,我们也不会把它渲染成一个表格。

Stepping back even further, this isn't specific to

data:text/html,
abc
def

In these cases, Chrome agrees with us and disregards the flex display mode. (as revealed by the fact that "abc" and "def" end up being stacked vertically). The fact that they happen to do what you're expecting on

In Gecko's button implementation, we hardcode

If you want to reliably have the children reliably arranged in a particular layout mode in a cross-browser fashion, your best bet is to use a wrapper-div inside the button, just as you would need to inside of a

or a
.

如果您希望以跨浏览器的方式可靠地将子元素以特定的布局模式排列,最好的方法是在按钮中使用wrapper-div,就像您需要在

中一样。

Therefore, that bug was marked as "resolved invalid".

因此,该错误被标记为“已解析无效”。

There is also Bug 1047590 - display: flex; doesn't work in

, currently "unconfirmed".

还有Bug 1047590 - display: flex;未在

中工作,当前为“未确认”。


Good news: Firefox 46+ implements Flexbox for

. See bug 1230207.

好消息:Firefox 46+为

实现了Flexbox。看到错误1230207。

#2


8  

I find out this might be a bug on Chrome and Firefox where legend and fieldset are replaced elements.

我发现这可能是Chrome和Firefox上的一个bug,其中传奇和fieldset被替换为元素。

Bugs Reported:

Bug Chrome
Bug Firefox

Chrome Bug火狐

A possible Workaround:

A possible workaround would be using

in HTML, and applying in CSS div[role='group'] as selector.

一个可能的解决方案是在HTML中使用

,在CSS div[role='group']中应用作为选择器。

#3


4  

In my experience, I've found that neither

, nor

As others have already mentioned, bugs have been reported. If you want to use flexbox to control ordering (e.g. order:2), then you'd need to wrap the element in a div. If you want flexbox to control actual layout and dimensions, then you may want to consider using a div, instead of the input control (Which stinks, I know).

正如其他人已经提到的,已经报告了错误。如果您想使用flexbox来控制排序(例如:order:2),那么您需要将元素封装到div中。

#4


2  

foo

bar

foo

bar

Might need to use role-group because firefox, chrome and i think safari have a bug with fieldsets apparently. Then the selector in the CSS would simply be

可能需要使用角色组,因为firefox、chrome和我认为safari显然有一个带有字段集的bug。那么CSS中的选择器就是

div[role='group'], div {
    display: flex;
    border: 1px solid;
}

Edit: Here are some issues that other people are experiencing as well.

编辑:这里有一些其他人正在经历的问题。

Issue 375693

发行375693

Issue 262679

发行262679

#5


-3  

you can put additional div in

with the following props:

您可以在

中添加以下工具:

flex-inner-wrapper {
  display: inherit;
  flex-flow: inherit;
  justify-content: inherit;
  align-items: inherit;
}

推荐阅读
  • 在DIV内垂直居中UL - Centering Vertically an UL inside a DIV
    iamtryingtomakeanavigationmenuinsidea200pxx200pxsquare,thisnavigationlist(UL)chang ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • Voicewo在线语音识别转换jQuery插件的特点和示例
    本文介绍了一款名为Voicewo的在线语音识别转换jQuery插件,该插件具有快速、架构、风格、扩展和兼容等特点,适合在互联网应用中使用。同时还提供了一个快速示例供开发人员参考。 ... [详细]
  • 拥抱Android Design Support Library新变化(导航视图、悬浮ActionBar)
    转载请注明明桑AndroidAndroid5.0Loollipop作为Android最重要的版本之一,为我们带来了全新的界面风格和设计语言。看起来很受欢迎࿰ ... [详细]
  • Android开发实现的计时器功能示例
    本文分享了Android开发实现的计时器功能示例,包括效果图、布局和按钮的使用。通过使用Chronometer控件,可以实现计时器功能。该示例适用于Android平台,供开发者参考。 ... [详细]
  • Java图形化计算器设计与实现
    本文介绍了使用Java编程语言设计和实现图形化计算器的方法。通过使用swing包和awt包中的组件,作者创建了一个具有按钮监听器和自定义界面尺寸和布局的计算器。文章还分享了在图形化界面设计中的一些心得体会。 ... [详细]
  • 本文整理了常用的CSS属性及用法,包括背景属性、边框属性、尺寸属性、可伸缩框属性、字体属性和文本属性等,方便开发者查阅和使用。 ... [详细]
  • 今天就跟大家聊聊有关怎么在Android应用中实现一个换肤功能,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根 ... [详细]
  • android:EditText属性去边框EditText继承关系:View--TextView--EditTextEditText的属性很多,这里介绍几个:android:h ... [详细]
  • 前端~javascript~webAPI/文档对象模型Dom/Dom树/事件机制/操作元素/实战案例:实现网页计数器
    文章目录WebAPI简介DomDom树获取Dom元素事件事件三要素操作dom元素innerHTMLinnerText实战案例:实现网页计数器WebAPI简介什么是AP ... [详细]
  • 前端实用的CSS3技巧有哪些
    本文小编为大家详细介绍“前端实用的CSS3技巧有哪些”,内容详细,步骤清晰,细节处理妥当,希望这篇“前端实用的CSS3技巧有哪些”文章能帮助大家 ... [详细]
  • 可能我们在看一些网页的源码时会发现自己从来没见过的属性或用法今天我就来总结一下CSS3的冷知识样式计算在CSS中也可以进行简单的计算通过calc函数可以实现这样还可以使我们的 ... [详细]
  • 1.CSS3透明度渐变(从左到右)#grad{background:-webkit-linear-gradient(left,rgba(198,226,255,1),rgba(19 ... [详细]
  • 1、给边框加上圆角及阴影,如下代码:<!DOCTYPEhtmlPUBLIC"-W3CDTDHTML4.01TransitionalEN"" ... [详细]
  • http:js.alixixi.coma2014021292298.shtmlhttp:w3cshare.comexample?pid134http:w3cshare.comc ... [详细]
author-avatar
前所未闻啊_549
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有